import { request } from "@/utils/request"
import type { HomePageItem, CountryCodeItem } from "@/types"
import type { HttpResponse } from "@/types/request"

interface HomePageResponse extends HttpResponse {
  data: {
    blocks: HomePageItem[]
  }
}

interface CountriesResponse extends HttpResponse {
  data: CountryCodeItem[]
}

//获取 APP 首页信息
export const getAppHome = (refresh: boolean): Promise<HomePageResponse> => request<HomePageResponse>({
  url: "/homepage/block/page",
  data: {
    refresh
  }
})

// 国家编码列表
export const getCountryCodeList = (): Promise<CountriesResponse> => request<CountriesResponse>({
  url: "/countries/code/list"
})

// 所有榜单
export const getTopList = (): Promise<HttpResponse> => request<HttpResponse>({
  url: "/toplist"
})

// 所有榜单内容摘要
export const getTopListDetail = (): Promise<HttpResponse> => request<HttpResponse>({
  url: "/toplist/detail"
})